export function getTimer(stringTime) {
    const minute = 1000 * 60
    const hour = minute * 60
    const day = hour * 24
    const week = day * 7
    const month = day * 30
    const time1 = new Date().getTime()// 当前的时间戳
    const time2 = Date.parse(new Date(stringTime))// 指定时间的时间戳
    const time = time1 - time2
    let result = null
    if (time < 0) {
        alert('设置的时间不能早于当前时间！')
    } else if (time / month >= 1) {
        if (time / month > 12) {
            return stringTime
        }
        result = '' + parseInt(time / month) + '个月前'
    } else if (time / week >= 1) {
        result = '' + parseInt(time / week) + '周前'
    } else if (time / day >= 1) {
        result = '' + parseInt(time / day) + '天前'
    } else if (time / hour >= 1) {
        result = '' + parseInt(time / hour) + '小时前'
    } else if (time / minute >= 1) {
        result = '' + parseInt(time / minute) + '分钟前'
    } else {
        result = '刚刚'
    }
    return result
}
